<%@ page contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	request.setCharacterEncoding("UTF-8");
	String cp = request.getContextPath(); 
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript" src="<%=cp%>/data/js/jquery-1.8.2.min.js"></script>
<script type="text/javascript">
	$(function(){
		$("#sendButton").click(function(){
			var params = "subject=" +$("#subject").val() + "&content=" + $("#content").val();
			
			$.ajax({
				type:"post", //방식
				url:"result1.jsp", 
				data:params, //가지고 갈 데이터들
				dataType:"xml", //데이터들의 타입
				success:function(args){ //성공했을때
					
					$(args).find("status").each(function(){
						alert($(this).text());
					});
					
					var str= "";
					$(args).find("record").each(function(){
						var id = $(this).attr("id");
						var subject = $(this).find("subject").text();
						var content = $(this).find("content").text();
						
						str += "id=" +id+ ", subject= " +subject+ ", content=" +content+ "<br/>";
					});
					
					$("#result").html(str);
				},
				beforeSend:showRequest, //보내기전에
				error:function(e){ //에러나면
					alert(e.responseText);
				}
			});
		});
	});
	
	function showRequest(){
		return true;
	}
</script>
</head>
<body>

제목 : <input type="text" id="subject"/><br/>
내용: <input type="text" id="content"/><br/>
<input type="button" id="sendButton" value="보내기"/>
<br/>
<br/>
<div id="result"></div> <!-- 값은 요기에 뿌려줌. -->

</body>
</html>